package com.liholin.springboot.sample.utils;

import java.lang.reflect.Method;
import java.util.Locale;

public class ReflectUtils {
    public static Method getGetMethod(Class<?> objectclass, String fieldName) {
        StringBuilder sb = new StringBuilder();
        sb.append("get");
        sb.append(fieldName.substring(0, 1).toUpperCase(Locale.ROOT));
        sb.append(fieldName.substring(1));
        try {
            return objectclass.getMethod(sb.toString());
        } catch (NoSuchMethodException e) {
            throw new RuntimeException("Reflect error!");
        }
    }
}